<template>
  <div id="app">
    <Spin size="large" fix class="app-spin" v-if="appSpinShow">
      <Icon type="ios-loading" size="18" class="spin-icon-load"></Icon>
      <div>Loading</div>
    </Spin>
    <router-view/>
  </div>
</template>

<script>
import { mapState } from 'vuex';
export default {
  name: 'App',
  computed: {
    ...mapState({
      appSpinShow: state => state.app.appSpinShow
    })
  },
  mounted () {
    // 如果有用户信息，直接跳到首页
    if (localStorage.userToken) {
      this.$cookies.set('access_token', localStorage.userToken);
    }
  }
};
</script>

<style lang="less">
#app {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
}

.page-bg {
  height: 100%;
  background-color: #132a60;
  background-image: url("~assets/images/bg.jpg");
  background-position: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.app-spin {
  background-color: rgba(0, 0, 0, 0.7)!important;
  z-index:9999!important;
}

.spin-icon-load {
  font-size: 28px!important;
  animation: ani-spin 1s linear infinite;
}
@keyframes ani-spin {
  from {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(180deg);
  }
  to {
    transform: rotate(360deg);
  }
}
</style>
